/* 
 * Copyright (C) 2012 Martin Řehánek <rehan at mzk.cz>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


goog.provide('kramerius.audio.test.Container');

goog.require('goog.ui.Container');
goog.require('goog.ui.Tooltip');


kramerius.audio.test.Container = function(container, title){
    this.container_ = container;
    this.title_ = title;
    this.init();
}


kramerius.audio.test.Container.prototype.init = function(){
    var hc = new goog.ui.Container(goog.ui.Container.Orientation.HORIZONTAL);
    //hc.setId('');
    //hc.g
    
    //hc.addClassName('playlist-item');
    // Pre-render the container, just to do something different.
    hc.render(this.container_);
    //    goog.array.forEach(
    //        ['Happy', 'Sleepy', 'Doc', 'Bashful', 'Sneezy', 'Grumpy', 'Dopey'],
    //        function(item) {
    //          var c = new goog.ui.Control(item);
    //          c.addClassName('goog-inline-block');
    //          c.setId(item);
    //          // For demo purposes, have controls dispatch transition events.
    //          c.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
    //          hc.addChild(c, true);
    //        });
    //    hc.getChild('Doc').setEnabled(false);
    var titleCtrl = new goog.ui.Control(this.title_);
    titleCtrl.addClassName('playlist-item-title');
    titleCtrl.setId(this.title_);
    //titleCtrl.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
    //titleCtrl.setDispatchTransitionEvents(goog.ui.Component.State.NONE, true);
    hc.addChild(titleCtrl, true);
    //nechapu, porad je tam "klikaci" kurzor
    titleCtrl.setEnabled(false);
    titleCtrl.setActive(false);
    
    
    //button up
    var moveUpCtrl = new goog.ui.Control();
    moveUpCtrl.addClassName('playlist-item-up');
    //moveUpCtrl.addClassName('playlist-item');
    //moveUpCtrl.setId("up");
    moveUpCtrl.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
    goog.events.listen(moveUpCtrl, goog.ui.Component.EventType.ACTION,
        function (e) {
            alert("TODO: move up in menu");
            //a pokud uz nejde pohnout nahoru, tak disable
        });
    hc.addChild(moveUpCtrl, true);
    moveUpCtrl.setEnabled(true);
    
    //button down
    var moveDownCtrl = new goog.ui.Control();
    moveDownCtrl.addClassName('playlist-item-down');
    console.log("move down: " + moveDownCtrl);
    new goog.ui.Tooltip(moveDownCtrl.getElement(), "posunout nahoru");
    //moveDownCtrl.addClassName('playlist-item');
    //moveDownCtrl.setId("down");
    moveDownCtrl.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
    goog.events.listen(moveDownCtrl, goog.ui.Component.EventType.ACTION,
        function (e) {
            alert("TODO: move down in menu");
        });
    hc.addChild(moveDownCtrl, true);
    
    //button remove
    var removeCtrl = new goog.ui.Control();
    removeCtrl.addClassName('playlist-item-remove');
    //removeCtrl.addClassName('playlist-item');
    //removeCtrl.setId("remove");
    removeCtrl.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
    goog.events.listen(removeCtrl, goog.ui.Component.EventType.ACTION,
        function (e) {
            alert("TODO: remove from menu");
        });
    hc.addChild(removeCtrl, true);
}

kramerius.audio.test.Container.prototype.getContainer = function(){
    return this.container_;
}




